/*
 * CPFCNPJValidatorTag.java
 *
 * Created on 13 de Maio de 2007, 19:25
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package net.sf.jOpinionPoll.tag.validator;

import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.webapp.ValidatorELTag;
import javax.servlet.jsp.JspException;

/**
 *
 * @author erico
 */
public class RegexValidatorTag extends ValidatorELTag {
	private static final long serialVersionUID = 1L;
	
    private String m_ExpressaoRegular;
    public static final String VALIDATOR_ID = "RegexValidator";
    
    /** Creates a new instance of CPFCNPJValidatorTag */
    public RegexValidatorTag() {
    	setId(VALIDATOR_ID);
    }
    
    public Validator createValidator() throws JspException {
    	FacesContext facesContext = FacesContext.getCurrentInstance();
        RegexValidator validator;
        
        validator = (RegexValidator)facesContext.getApplication().createValidator(getId());
        validator.setExpressaoRegular(getExpressaoRegular());
        
        return validator;
    }
    
    public String getExpressaoRegular() {
        return m_ExpressaoRegular;
    }
    
    public void setExpressaoRegular(String expressaoRegular) {
        this.m_ExpressaoRegular = expressaoRegular;
    }
    
    public void release() {
    	super.release();
    	
    	setExpressaoRegular(null);
    }
}